import type { FC } from 'react';
import { View } from 'react-native';
import { useMemoizedFn } from 'ahooks';
import FilterTabs from '@/components/FilterTabs';
import AddButton from './components/AddButton';
import PageContent from './content';
import { openCreatePage } from '@/pages/createPost';
import styles from './styles';

const tabs = [
  {
    title: 'For you',
    value: 'recommend'
  },
  {
    title: 'Following',
    value: 'follow'
  }
];

const Posts: FC = () => {
  const toCreatePage = useMemoizedFn(() => {
    openCreatePage();
  });

  return (
    <View style={styles.container}>
      <FilterTabs filters={tabs}>
        {(item, setIndex) => (
          <PageContent
            setIndex={setIndex}
            pageKey={item.value}
          />
        )}
      </FilterTabs>
      <AddButton onPress={toCreatePage} />
    </View>
  );
}

export default Posts;